<!--

 Copyright 2018-present Sonatype, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

-->

<div class="artifact" fxLayout="column" fxFill [@slideUp]>

  <div fxLayout="column" fxLayout.gt-sm="row" fxFlex.lt-md="135px">

    <div class="artifact-info" fxLayout="column" fxFlex="100" fxLayout.gt-sm="row" fxFlex.gt-sm="65">

      <div fxLayout="column" fxFlex="100" fxLayout.gt-sm="row">

        <div class="artifact-title">
          <span class="ellipsis">{{ group + ':' + artifact }}:</span>
        </div>

        <mat-form-field class="more-versions-from-field">

          <mat-select [(value)]="version">
            <mat-option *ngFor="let doc of searchDocs" [value]="doc.v">
              <a [routerLink]="['/artifact', doc.g, doc.a, doc.v, doc.p]">{{ doc.v }}</a>
            </mat-option>
          </mat-select>

        </mat-form-field>

      </div>

      <div class="vulnerability-spinner" *ngIf="showVulnerabilitySpinner">
        <mat-spinner diameter="35"></mat-spinner>
      </div>

      <div class="artifact-vulnerabilities" fxLayout="column" *ngIf="componentReport">

        <div class="vulnerability-prefix" *ngIf="componentReport?.vulnerabilities.length > 0">
          {{ 'artifact.vulnerabilities' | translate}}
        </div>

        <div fxLayout="row">

          <div class="vulnerability-chip"
               *ngIf="componentReport.criticalCount > 0">
            <a href="{{ ossVulnerabilitiesResourceLink() }}"
               target="_blank"
               mat-raised-button
               class="vulnerability-link critical">
              {{ componentReport.criticalCount }} {{ 'artifact.criticalVulnerability' | translate}}
            </a>
          </div>

          <div class="vulnerability-chip"
               *ngIf="componentReport.severeCount > 0">
            <a href="{{ ossVulnerabilitiesResourceLink() }}"
               target="_blank"
               color="warn"
               mat-raised-button
               class="vulnerability-link severe">
              {{ componentReport.severeCount }} {{ 'artifact.severeVulnerability' | translate}}
            </a>
          </div>

          <div class="vulnerability-chip"
               *ngIf="componentReport.moderateCount > 0">
            <a href="{{ ossVulnerabilitiesResourceLink() }}"
               target="_blank"
               color="warn"
               mat-raised-button
               class="vulnerability-link moderate">
              {{ componentReport.moderateCount }} {{ 'artifact.moderateVulnerability' | translate}}
            </a>
          </div>

          <div class="vulnerability-chip"
               *ngIf="componentReport.unknownCount > 0">
            <a href="{{ ossVulnerabilitiesResourceLink() }}"
               target="_blank"
               color="warn"
               mat-raised-button
               class="vulnerability-link unknown">
              {{ componentReport.unknownCount }} {{ 'artifact.unknownVulnerability' | translate}}
            </a>

          </div>

        </div>

      </div>

    </div>

    <div fxFlex fxHide fxShow.gt-sm></div>

    <div class="artifact-actions" fxHide fxShow.gt-sm>

      <a target="_blank"
         href="{{ repositoryLink(group, artifact, version) }}"
         mat-button>
        <span>{{ 'artifact.browse' | translate }}</span>
        <mat-icon>folder</mat-icon>
      </a>

      <button mat-button [matMenuTriggerFor]="menuDownloads">
        <span>{{ 'artifact.downloads' | translate }}</span>
        <mat-icon>file_download</mat-icon>
      </button>
      <mat-menu #menuDownloads="matMenu">
          <a *ngFor="let dl of downloadLinks"
             mat-menu-item 
             target="_blank" 
             href="{{ dl.link }}" >{{ dl.name }}</a>
      </mat-menu>
    </div>

  </div>

  <div class="artifact-details"
       fxLayout="row"
       fxLayout.lt-md="column"
       [ngClass]="{'vulnerabilities-spacer': componentReport?.vulnerabilities.length > 0 }">

    <div class="pom-dependency-information-column" fxFlex="65">

      <app-pom-dependency-information headerText="{{ group }}:{{ artifact }}"
                                      subText="{{ version }}"
                                      image="xml"
                                      value="{{ pom }}"
                                      *ngIf="pom"
                                      fxLayout="row"
                                      class="pom-dependency-information">
      </app-pom-dependency-information>

    </div>

    <div class="artifact-dependency-information-column" fxFlex="35">

      <app-dependency-information headerText="artifact.apacheMaven"
                                  subText="maven.apache.org"
                                  subTextUrl="https://maven.apache.org"
                                  image="mvn"
                                  type="maven"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}"
                                  p="{{packaging}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.gradle"
                                  subText="gradle.org"
                                  subTextUrl="https://gradle.org"
                                  image="gradle"
                                  type="gradle"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.gradleKotlinDsl"
                                  subText="github.com/gradle/kotlin-dsl"
                                  subTextUrl="https://github.com/gradle/kotlin-dsl"
                                  image="kotlin"
                                  type="kotlin"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.scalaSbt"
                                  subText="scala-sbt.org"
                                  subTextUrl="https://www.scala-sbt.org"
                                  image="scala"
                                  type="sbt"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.apacheIvy"
                                  subText="ant.apache.org/ivy/"
                                  subTextUrl="https://ant.apache.org/ivy/"
                                  image="ivy"
                                  type="ivy"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.groovyGrape"
                                  subText="groovy-lang.org/grape.html"
                                  subTextUrl="http://groovy-lang.org/grape.html"
                                  image="groovy"
                                  type="groovygrape"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.leiningen"
                                  subText="leiningen.org"
                                  subTextUrl="https://leiningen.org"
                                  image="leiningen"
                                  type="leiningen"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.apacheBuildr"
                                  subText="buildr.apache.org"
                                  subTextUrl="https://buildr.apache.org/"
                                  image="buildr"
                                  type="apachebuilder"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.mavenCentral"
                                  subText="search.maven.org"
                                  subTextUrl="https://search.maven.org"
                                  image="badge"
                                  type="maven-badge"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.purlSpec"
                                  subText="github.com/package-url/purl-spec"
                                  subTextUrl="https://github.com/package-url/purl-spec"
                                  image=""
                                  type="purl"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}">
      </app-dependency-information>

      <app-dependency-information headerText="artifact.bazel"
                                  subText="bazel.build"
                                  subTextUrl="https://www.bazel.build"
                                  image="bazel"
                                  type="bazel"
                                  g="{{group}}"
                                  a="{{artifact}}"
                                  v="{{version}}"
                                  s="{{sha1}}">
      </app-dependency-information>

    </div>

  </div>

</div>
